<!--
Copyright (C) 2007 James Ward
http://www.jamesward.org

Updated, Alex Russell, 2008
http://alex.dojotoolkit.org

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<html>
	<head>
		<!--
		<link rel="stylesheet" href="resources/main.css" type="text/css">
		-->
		<link rel="stylesheet" href="dojo/dijit/themes/dijit.css" type="text/css">
		<link rel="stylesheet" href="dojo/dojox/grid/resources/tundraGrid.css" type="text/css">
		<script type="text/javascript" src="dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
		<script type="text/javascript" src="dojo/dojo/cookie.js"></script>
		<script type="text/javascript" src="resources/timing.js"></script>
		<script type="text/javascript">
			dojo.require("dojo.cookie");
			dojo.require("dijit.dijit");
			dojo.require("dojox.grid.DataGrid");
			dojo.require("dojo.data.ItemFileReadStore");
			dojo.addOnLoad(function(){
				var url = new dojo._Url(window.location);
				var rows = 5000;
				if(url.query){
					rows = dojo.queryToObject(url.query).rows||rows;
				}
				timing.tic("transferTime");
				dojo.xhrGet({
					handleAs: "text",
					url: "data.jsp",
					content: {
						output: "json",
						count: rows,
						start: 0
					},
					load: function(data, ioArgs){
						try{
						var tt = timing.toc("transferTime");

						var st = parseInt(dojo.cookie("serverExecTime"));

						timing.setTime("serverExecTime", st);
						timing.setTime("transferTime", tt-st);

						timing.size("bandwidth", data);

						timing.tic("parseTime");
						var jsonData = dojo.fromJson(data);
						// console.log(jsonData);
						var dObj = {
							identifier: "id",
							label: "age",
							items: jsonData
						};
						ifrs._jsonData = dObj;
						ifrs._forceLoad();
						timing.toc("parseTime");

						timing.tic("renderTime");
						dGrid.setStore(ifrs, { age: '*' });
						timing.toc("renderTime");

						timing.report();
						}catch(e){ console.error(e); }
					}
				});
			});
		</script>
	</head>
	<body class="tundra">
		<div dojoType="dojo.data.ItemFileReadStore" jsId="ifrs"></div>
		<table dojoType="dojox.grid.DataGrid" jsId="dGrid"
			style="width: 100%; height: 100%;"
			width="100%" height="100%">
			<thead>
				<tr>
					<th>id</th>
					<th>age</th>
					<th>class</th>
					<th>education</th>
					<th>maritalStatus</th>
					<th>race</th>
					<th>sex</th>
				</tr>
			</thead>
		</table>
		<!--
		<div id="grid">
		</div>
		-->
	</body>
</html>
